package com.tbit.uqbike.service.base;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageInfo;
import com.tbit.common.entity.pojo.vo.ReturnBikeMsgLogVO;
import com.tbit.common.entity.view.Result;
import com.tbit.uqbike.object.business.Point;
import com.tbit.uqbike.object.pojo.HeatMapStat;
import com.tbit.uqbike.object.pojo.ParkPoint;
import com.tbit.uqbike.object.pojo.ParkPointMachineStat;
import com.tbit.uqbike.object.pojo.dto.GetReturnBikePointDTO;
import com.tbit.uqbike.object.pojo.dto.ParkPointMachineStaDownloadDTO;
import com.tbit.uqbike.object.pojo.statistics.ExportParkPoint;
import com.tbit.uqbike.object.pojo.vo.ParkPointMachineStatChartVO;
import com.tbit.uqbike.object.value.LoginInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * @author chenmengran
 * @Description: 停车点
 * @date 2019\12\12 001214:00
 */
public interface ParkPointService {

    /**
     * 添加停车点
     *
     * @param parkPoint
     * @param loginInfo
     */
    ParkPoint insert(ParkPoint parkPoint, LoginInfo loginInfo);

    /**
     * 更新
     *
     * @param parkPoint
     */
    ParkPoint update(ParkPoint parkPoint, LoginInfo loginInfo);

    /**
     * 删除
     *
     * @param parkPointId
     */
    void del(Integer parkPointId, LoginInfo loginInfo);

    /**
     * 获取代理商下的所有停车点
     *
     * @param accountId
     * @param loginInfo
     * @return
     */
    List<ParkPoint> getByAccountId(Integer accountId, LoginInfo loginInfo, List<Integer> regionIdList, Integer level);

    /**
     * 检测是否在站点
     *
     * @param accountId
     * @param point
     * @param radius
     * @return
     */
    Boolean checkInParkPoint(Integer accountId, Point point, Integer radius);

    /**
     * 根据代理商和半径查询
     *
     * @param accountId
     * @param lo
     * @param la
     * @param radius
     * @return
     */
    List<ParkPoint> getByAccountAndArea(Integer accountId, Double lo, Double la, Integer radius);

    /**
     * 根据停车点id查询
     *
     * @param parkPointId
     * @return
     */
    ParkPoint getByParkPointId(Integer parkPointId);

    /***
     * 分页查询停车点
     * @param loginInfo
     * @param accountId
     * @param machineNO
     * @param rowCount
     * @param pageNO
     * @return
     */
    PageInfo<ParkPoint> queryPage(LoginInfo loginInfo, Integer accountId, String machineNO, Integer rowCount, Integer pageNO,
                                  String sortItem, String name, List<Integer> regionIdList, Integer enable, String rfid,
                                  Integer siteType, Integer rfidType, Integer railSpikeType, Integer kickstandType,
                                  Integer cameraType,Integer level);

    /**
     * 获取总数
     *
     * @param accountId
     * @param machineNO
     * @return
     */
    Integer getTotal(Integer accountId, String name, String machineNO, List<Integer> regionList, Integer enable, String rfid, Integer siteType, Integer rfidType, Integer railSpikeType, Integer kickstandType, Integer cameraType);

    /**
     * 模糊查询
     *
     * @param loginInfo
     * @param accountId
     * @param name
     * @return
     */
    List<ParkPoint> queryByName(LoginInfo loginInfo, Integer accountId, String name);

    List<ParkPoint> getAll();

    /**
     * 站点热力图统计
     */
    List<HeatMapStat> statByPark(Integer accountId, Integer type, Long startTime, Long endTime, String regionIds);

    List<ExportParkPoint> selectParkPoint(Map<String, Object> map);

    void switchParkPoint(@Param("pSwitch") Integer pSwitch, @Param("parkPointId") Integer parkPointId);

    void batchAdd(MultipartFile file, Integer accountId, LoginInfo loginInfo, Integer mapType);

    /**
     * 获取对对应区域还车点
     *
     * @param dto
     * @return
     */
    List<ReturnBikeMsgLogVO> getReturnBikePoint(GetReturnBikePointDTO dto);

    /**
     * 获取站点类型
     * 高精度站点 经纬度小数位的长度大于6
     * 普通站点  经纬度小数位的长度小于等于6
     *
     * @param pointsStr 经纬度集合
     * @return 站点类型 0:普通站点  1:高精度站点
     */
    Integer getSiteType(String pointsStr);

    /**
     * 经纬度集合合法校验
     *
     * @param points 经纬度集合
     */
    void checkPoints(String points);

    void checkHighPrecisionAllowRange(Integer allowRange);

    Page<ParkPointMachineStat> selectParkPointMachineStatPage(Integer accountId, String startTime, String endTime, String regionIds,
                                                              String parkPointIds, String orderBy, Integer rowCount, Integer pageNO);

    String parkPointMachineStatExportCsv(ParkPointMachineStaDownloadDTO parkPointMachineStaDownloadDTO);

    List<ParkPointMachineStatChartVO> selectParkPointMachineStatChart(Integer accountId, String startTime, String endTime, String regionIds, String parkPointIds);

    /**
     * 站点数据导出
     * @param parkPointMachineStaDownloadDTO 导出参数
     * @return 文件名
     */
    Result<Object> parkPointMachineStatExport(ParkPointMachineStaDownloadDTO parkPointMachineStaDownloadDTO);

    /**
     * 根据区域id获取区域的站点是否大于10个
     *
     * @param accountId 区域id
     */
    Boolean isMaxParkPointCount(Integer accountId);

    /**
     * 根据accountId获取区域所有站点
     * @param accountId 区域id
     */
    List<ParkPoint> selectByAccountId(Integer accountId);

    /**
     * 根据站点id批量删除站点
     *
     * @param parkPointList 站点id集合
     */
    void batchDel(List<Integer> parkPointList);
}
